package com.bicon.life.core.base.config;

import com.bicon.life.core.base.common.Constants;
import com.bicon.life.core.base.common.entity.BaseResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 全局异常处理
 * @author tandk
 * @date 2017/6/12 0012 下午 4:27
 */
@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {
    @ExceptionHandler(value=Exception.class)
    public Object ExceptiondHandler(HttpServletRequest request, Exception exception) throws Exception {
        exception.printStackTrace();
        return new BaseResult(Constants.RESPONSE_CODE_500,Constants.RESPONSE_MESSAGE_500, exception.toString());
    }
}
